REM Build script for Wake-on-LAN toolkit

REM Set Visual Studio environment variables
call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars32.bat"

REM Build projects directly
set "BUILD_SUCCESS=0"

REM Build wolcmd project
if exist "wolcmd.sln" (
    echo Building wolcmd solution...
    msbuild "wolcmd.sln" /p:Configuration=Release /p:Platform=Win32 /t:Rebuild
    if errorlevel 1 (
        echo wolcmd build failed!
        set "BUILD_SUCCESS=1"
    )
) else (
    echo wolcmd solution file not found!
    set "BUILD_SUCCESS=1"
)

REM Check overall build result
if %BUILD_SUCCESS% EQU 0 (
    echo All projects built successfully!
    echo Searching for executable files...
    dir /s /b *.exe | findstr /i "Release"
) else (
    echo Build failed! Some projects did not compile successfully.
)

REM Pause to view output
pause